<html>
<head>
  <script src="../lib/OpenLayers.js"></script>
  <script type="text/javascript"><!--

    var lonlat; 

    function test_01_LonLat_constructor (t) {
        t.plan( 4 );
        lonlat = new OpenLayers.LonLat(6, 5);
        t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" );
        t.eq( lonlat.CLASS_NAME, "OpenLayers.LonLat", "lonlat.CLASS_NAME is set correctly");
        t.eq( lonlat.lon, 6, "lonlat.lon is set correctly");
        t.eq( lonlat.lat, 5, "lonlat.lat is set correctly");
    }

    function test_02_LonLat_toString(t) {
        t.plan( 1 );
        lonlat = new OpenLayers.LonLat(5,6);
        t.eq( lonlat.toString(), "lon=5,lat=6", "lonlat.toString() returns correctly");
    }

    function test_02A_LonLat_toShortString(t) {
        t.plan( 1 );
        lonlat = new OpenLayers.LonLat(5,6);
        t.eq( lonlat.toShortString(), "5, 6", "lonlat.toShortString() returns correctly");
    }

    function test_03_LonLat_copyOf(t) {
        t.plan( 4 );
        oldLonLat = new OpenLayers.LonLat(5,6);
        lonlat = oldLonLat.copyOf();
        t.ok( lonlat instanceof OpenLayers.LonLat, "copyOf returns new OpenLayers.LonLat object" );
        t.eq( lonlat.lon, 5, "lonlat.lon is set correctly");
        t.eq( lonlat.lat, 6, "lonlat.lat is set correctly");
        
        oldLonLat.lon = 100;
        t.eq( lonlat.lon, 5, "changing oldLonLat.lon doesn't change lonlat.lon");
    }

    function test_04_LonLat_add(t) {
        t.plan( 4 );

        lonlatA = new OpenLayers.LonLat(10,100);

        addpx = lonlatA.add(5, 50);
        t.eq( lonlatA.lon, 10, "lonlatA.lon is not modified by add operation");
        t.eq( lonlatA.lat, 100, "lonlatA.lat is not modified by add operation");

        t.eq( addpx.lon, 15, "addpx.lon is set correctly");
        t.eq( addpx.lat, 150, "addpx.lat is set correctly");
    }
    
    function test_06_LonLat_equals(t) {
        t.plan( 5 );
        lonlat = new OpenLayers.LonLat(5,6);

        ll = new OpenLayers.LonLat(5,6);
        t.eq( lonlat.equals(ll), true, "(5,6) equals (5,6)");

        ll = new OpenLayers.LonLat(1,6);
        t.eq( lonlat.equals(ll), false, "(5,6) does not equal (1,6)");

        ll = new OpenLayers.LonLat(5,2);
        t.eq( lonlat.equals(ll), false, "(5,6) does not equal (5,2)");

        ll = new OpenLayers.LonLat(1,2);
        t.eq( lonlat.equals(ll), false, "(5,6) does not equal (1,2)");

        t.ok( !lonlat.equals(null), "equals() returns false on comparison to null");

    }

    function test_07_LonLat_fromString(t) {
        t.plan( 3 );
        lonlat = OpenLayers.LonLat.fromString("6,5");
        t.ok( lonlat instanceof OpenLayers.LonLat, "new OpenLayers.LonLat returns LonLat object" );
        t.eq( lonlat.lon, 6, "lonlat.lon is set correctly");
        t.eq( lonlat.lat, 5, "lonlat.lat is set correctly");
    }

  // -->
  </script>
</head>
<body>
</body>
</html>
